home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / tsr_c.exe / CHAIN.ASM < prev    next >
Assembly Source File  |  1992-03-21  |  1KB  |  51 lines

  1. .model large
  2.  
  3. .code
  4. ;   The stack frame looks like this:
  5. ;
  6. ;       | flags   |   - foreground flags
  7. ;       | segment |   - foreground segment to return to
  8. ;       | offset  |   -      "     offset   "      "
  9. ;       | ax      |   - regs:
  10. ;       | bx      |
  11. ;       | cx      |
  12. ;       | dx      |
  13. ;       | es      |
  14. ;       | ds      |
  15. ;       | si      |
  16. ;       | di      |
  17. ;       | bp      |
  18. ;       | ??????  |   - local variables
  19. ;       | new seg |   - segment to chain to
  20. ;       | new off |   - offset   "      "
  21. ;       | segment |   - segment from call to _chain
  22. ;       | offset  |   - offset from call to _chain
  23. ;
  24.  
  25. chain_addr dd ?                               ; code segment variable for
  26.                                               ;   addr to chain to
  27.  
  28. _chain proc
  29.         pop cx                                ; discard segment to return to
  30.         pop cx                                ; discard offset to return to
  31.         pop word ptr cs:[chain_addr]          ; save chain offset
  32.         pop word ptr cs:[chain_addr+2]        ; save chain segment
  33.  
  34.         mov sp, bp                            ; reset stack frame
  35.         pop bp
  36.         pop di
  37.         pop si
  38.         pop ds
  39.         pop es
  40.         pop dx
  41.         pop cx
  42.         pop bx
  43.         pop ax
  44.  
  45.         jmp dword ptr cs:[chain_addr]         ; chain to address
  46. _chain  endp
  47.  
  48. public _chain
  49.  
  50. end
  51.